package com.syzygy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.syzygy.mapper.PictureMapper;
import com.syzygy.pojo.Picture;
import com.syzygy.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PictureServiceImpl implements PictureService {
    @Autowired
    private PictureMapper pictureMapper;

    @Override
    public List<String> getAllPictureId() {
        return pictureMapper.getAllPictureId();
    }

    @Override
    public Picture getPictureById(String pictureId) {
        return pictureMapper.getPictureById(pictureId);
    }

//    @Override
//    public List<Picture> getAllPictureAndUser() {
//        return pictureMapper.getAllPictureAndUser();
//    }

    @Override
    public List<Picture> getAllPicture() {
        return pictureMapper.getAllPicture();
    }

    @Override
    public int uploadPicture(String pictureId, String pictureDocumentName, int userId, int typeId, double price, String describe) {
        return pictureMapper.uploadPicture(pictureId, pictureDocumentName, userId, typeId, price, describe);
    }

    @Override
    public List<Picture> getPicturesByUserId(int userId) {
        return pictureMapper.getPicturesByUserId(userId);
    }

    @Override
    public List<Picture> getPicturesByTypeId(int typeId) {
        return pictureMapper.getPicturesByTypeId(typeId);
    }

    @Override
    public int updatePictureByPictureId(String describe, int typeId, double price, String pictureId) {
        return pictureMapper.updatePictureByPictureId(describe, typeId, price, pictureId);
    }

    @Override
    public int deletePictureByPictureId(String pictureId) {
        return pictureMapper.deletePictureByPictureId(pictureId);
    }

    @Override
    public int updateStateByPictureId(String state, String pictureId) {
        return pictureMapper.updateStateByPictureId(state,pictureId);
    }

    @Override
    public PageInfo<Picture> getPicturePage(Integer pageNumber) {
//        每页五数据
        PageHelper.startPage(pageNumber,10);
        List<Picture> allPictures = pictureMapper.getAllPicture();
//        获取分页数据 导航分页共五页
        PageInfo<Picture> page = new PageInfo<>(allPictures,10);
        return page;
    }


}
